
import mx.controls.Text;
import mx.events.ValidationResultEvent;
import mx.managers.PopUpManager;

private var msg:Array = new Array();

public function get Messages():Array{
	return this.msg;
}

public function set Messages(msg:Array):void{
	this.msg = msg;
}

private function windowCreated():void{
	this.height = 60 + 22*msg.length;
	showMessages();
}

private function closeMe():void{
	PopUpManager.removePopUp(this);
}

private function showMessages():void{
	msg = msg.reverse();
	var msgObj:Object = null;
	
	var count:int = msg.length;
	for(var i:int = 0; i<count; i++){
		var lbl:Text = new Text();
		
		
		msgObj = msg.pop();
		
		lbl.text = "  " + (i+1).toString() + ". " 
		if(msgObj is ValidationResultEvent){
			lbl.text += (msgObj as ValidationResultEvent).message;
		}else if(msgObj is String){
			lbl.text += msgObj.toString();
		}
		lbl.percentWidth = 100;
		messagesBox.addChild(lbl);
	}
}